# ! /usr/bin/env python
# coding = utf-8
import os
import time
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

def savePngName(name):
    tm = time.strftime('%Y-%m-%d-%H_%M_%S', time.localtime(time.time()))
    day = time.strftime('%Y-%m-%d', time.localtime(time.time()))
    fp = "..\\result\\" + day + "\\image\\"
    if os.path.exists(fp):
        filename = str(fp) + str(tm) + str("_") + str(name) + ".png"
        print filename
        return filename
    else:
        os.makedirs(fp)
        filename = str(fp) + str(tm) + str("_") + str(name) + ".png"
        print filename
        return filename

def saveScreenshot(driver, name):
    image = driver.save_screenshot(savePngName(name))
    return image
